<?php

declare(strict_types=1);

namespace Frontend\Helpers;

use DateTime;
use DateTimeZone;

class Format
{
    public static function money(float|int|string|null $value, string $currency = 'USDT'): string
    {
        if ($value === null) {
            return '-';
        }
        $number = (float) $value;
        return number_format($number, 2) . ' ' . $currency;
    }

    public static function datetime(?string $iso, string $timezone = 'Asia/Tokyo'): string
    {
        if (!$iso) {
            return '-';
        }
        try {
            $dt = new DateTime($iso);
            $dt->setTimezone(new DateTimeZone($timezone));
            return $dt->format('Y-m-d H:i');
        } catch (\Exception) {
            return $iso;
        }
    }

    public static function status(string $status): string
    {
        return ucfirst(strtolower(str_replace('_', ' ', $status)));
    }
}

